package com.lqfan.autoAnswerQ.dao.reportCard;

import com.lqfan.autoAnswerQ.model.reportCard.ReportCard;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zml
 * @since 2020-05-04
 */
@Mapper
public interface ReportCardMapper extends BaseMapper<ReportCard> {
    /**
     * 插入成绩单
     * @param reportCard
     * @return
     */
    @Insert("insert into reportCard (id,questionId,score,info,name,userId) values " +
            "(#{id},#{questionId},#{score},#{info},#{name},#{userId})")
    boolean insertRecordCard(ReportCard reportCard);

    /**
     * 获取所有成绩单的题库展示
     */
    @Select("select * from reportCard where userId =#{userId} group by questionId")
    List<ReportCard> getReportCard(String userId);

    /**
     * 获取该题库的所有成绩单
     * @param userId
     * @param questionId
     * @return
     */
    @Select("select * from reportCard where userId=#{userId} and questionId =#{questionId}")
    List<ReportCard> getReportCardInfo(String userId,String questionId);

    /**
     * 删除该题库的所有成绩单
     */
    @Delete("delete from reportCard where questionId=#{questionId} and userId=#{userId}")
    boolean deleteReportCard(String questionId,String userId);
    /**
     * 删除题库的整个成绩单
     * @param reportCardId
     * @return
     */
    @Delete("delete from reportCard where id=#{reportCardId} and userId=#{userId}")
    boolean deleteReportCardInfo(String reportCardId,String userId);
}
